home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / DYN401.ZIP / class / stream.c < prev    next >
C/C++ Source or Header  |  1997-04-16  |  2KB  |  118 lines

  1.  
  2.  
  3. /*  Copyright (c) 1993-1996 Algorithms Corporation  */
  4. /*  All rights reserved.  */
  5.  
  6.  
  7.  
  8.  
  9. /*  This file automatically generated by dpp - do not edit  */
  10.  
  11. #define    DPP_STRATEGY    2
  12. #define    DPP_FASTWIDE    0
  13.  
  14.  
  15.  
  16. #line 15 "stream.d"
  17. #include <string.h> 
  18.  
  19. #define    CLASS    Stream_c
  20. #define    ivType    Stream_iv_t
  21.  
  22. #include "generics.h"
  23.  
  24. object    Stream_c;
  25.  
  26.  
  27. #line 23 "stream.d"
  28. object stdoutStream_o, stdinStream_o, stderrStream_o, traceStream_o; 
  29.  
  30.  
  31. imeth int Stream_im_gPuts(object self, char *str)
  32.     if (IsObj((object)str)) 
  33.         str = gStringValue((object)str); 
  34.     return gWrite(self, str, strlen(str)); 
  35.  
  36. imeth int Stream_im_gPutc(object self, int i)
  37.     char c = (char) i; 
  38.     return 1 == (gWrite(self, &c, 1)) ? i : EOF; 
  39.  
  40. ivmeth int Stream_ivm_vPrintf(object self, va_list _rest_)
  41. { char * fmt = va_arg(_rest_, char *);
  42.     char buf[256]; 
  43.     MAKE_REST(fmt); 
  44.  
  45.     vsprintf(buf, fmt, _rest_); 
  46.     return gWrite(self, buf, strlen(buf)); 
  47.  
  48. #line 54 "stream.c"
  49.  
  50. static    int    Stream_ifm_vPrintf(object self, ...)
  51. {
  52.     va_list    _rest_;
  53.     va_start(_rest_, self);
  54.     return Stream_ivm_vPrintf(self, _rest_);
  55. }
  56.  
  57.  
  58.  
  59. #line 48 "stream.d"
  60. imeth objrtn Stream_im_gCopy(object self)
  61.     return gShouldNotImplement(self, "Copy/DeepCopy"); 
  62.  
  63. static void class_init(void) 
  64.     Dynace; 
  65.     RegisterVariable(stdoutStream_o); 
  66.     RegisterVariable(stderrStream_o); 
  67.     RegisterVariable(stdinStream_o); 
  68.     RegisterVariable(traceStream_o); 
  69.  
  70. #line 80 "stream.c"
  71.  
  72. objrtn    Stream_initialize(void)
  73. {
  74.     static  CRITICALSECTION  cs;
  75.     static  int volatile once = 0;
  76.  
  77.     ENTERCRITICALSECTION(_CI_CS_);
  78.     if (!once) {
  79.         INITIALIZECRITICALSECTION(cs);
  80.         once = 1;
  81.     }
  82.     LEAVECRITICALSECTION(_CI_CS_);
  83.  
  84.     ENTERCRITICALSECTION(cs);
  85.  
  86.     if (Stream_c) {
  87.         LEAVECRITICALSECTION(cs);
  88.         return Stream_c;
  89.     }
  90.     INHIBIT_THREADER;
  91.     Stream_c = gNewClass(Class, "Stream", 0, 0, END);
  92.     iMethodFor(Stream, gPuts, Stream_im_gPuts);
  93.     ivMethodFor(Stream, vPrintf, Stream_ivm_vPrintf, Stream_ifm_vPrintf);
  94.     iMethodFor(Stream, gPutc, Stream_im_gPutc);
  95.     iMethodFor(Stream, gCopy, Stream_im_gCopy);
  96.     iMethodFor(Stream, gDeepCopy, Stream_im_gCopy);
  97.  
  98.     class_init();
  99.  
  100.     ENABLE_THREADER;
  101.  
  102.     LEAVECRITICALSECTION(cs);
  103.  
  104.     return Stream_c;
  105. }
  106.  
  107.  
  108.  
  109.